package cn.baiyang.rocketmq.example.producer;

import javax.annotation.Resource;

import org.apache.rocketmq.client.apis.ClientException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import cn.baiyang.rocketmq.spring.core.RocketMQProducerTemplate;

/**
 *
 * @author hongzhu
 * @version V1.0
 * @since 2023-03-13 11:40
 */
@Component
@ConditionalOnProperty(prefix = "rocketmq-java", value = {"producer.topics"})
public class TemplateExample {

    @Resource
    private RocketMQProducerTemplate producerTemplate;

    @Value("${business.topic}")
    private String topic;

    @Value("${business.tag}")
    private String tag;

    public String testSending(String body) throws ClientException {
        return producerTemplate.send(topic, tag, body);
    }

}
